package punctuatedEquilibriumTest;

import static org.junit.Assert.*;

import org.junit.Test;

import punctuatedEquilibrium.FloatComparison;

public class FloatComparisonTest extends FloatComparison {
	private static final double	EXPECTED_VALUE	= 1;

	@Test
	public void testTolerableErrorFromExpectedValue() {
		double tolerableError = FloatComparison
				.tolerableErrorDependingOnExpectedValue(EXPECTED_VALUE);
		assertTrue((tolerableError > EXPECTED_VALUE / 1000000));
	}

	@Test
	public void testEquals() {
		double expected = 1d;
		double actual = 1d;
		assertTrue(FloatComparison.equals(expected, actual));
	}

	@Test
	public void testEqualsWithTolerableError() {
		double expected = 1d;
		double actual = 1.000000000000000000001d;
		assertTrue(FloatComparison.equals(expected, actual));
	}

	@Test
	public void testNotEquals() {
		double expected = 1d;
		double actual = 2d;
		assertFalse(FloatComparison.equals(expected, actual));
	}

	@Test
	public void testAlsoNotEquals() {
		double expected = 1d;
		double actual = 1.001d;
		assertFalse(FloatComparison.equals(expected, actual));
	}
}
